/**
 * 首页
 */
import { useState, useEffect } from "react";
import { IndexDomain } from "../../services"; // service
import type { IndexVo } from "../../interface/index/indexDto"; // vo

export default function Index(): JSX.Element {
    // 展示数据
    const [indexData, setIndexData] = useState<IndexVo[]>([]);
    // effect执行
    useEffect(() => {
        getIndexData();
    }, []);
    /**
     * 获取展示数据, 并赋值data
     * @method
     */
    async function getIndexData() {
       const data = await IndexDomain.queryIndexData({id: 1});
       setIndexData(data);
    }

    return (
        <div className="app">
            {indexData.map((item: IndexVo, index: number) => (
                <div key={index}>姓名: { item.name } / 年龄：{ item.age }</div>
            ))}
        </div>
    )
}